/**
  ETFRoot project, Anyang Normal University && IMP-CAS
  \class ETFGlobalTracker
  \brief for tracking around the reaction target with united tracking algorithm,
  making use of postMag track info and preTaTrk-postTaTrk inconsistencies
  \author SUN Yazhou, asia.rabbit@163.com
  \since 2021-11-10
  \date 2021-11-23 last modified
  \attention
  changelog
  <table>
  <tr>  <th>Date         <th>Author      <th>Description                   </tr>
  <tr>  <td>2021-11-10   <td>Asia Sun    <td>file created                  </tr>
  </table>

  \copyright Copyright (c) 2021 Anyang Normal U. && IMP-CAS with LGPLv3 LICENSE
*/

#ifndef ETFGlobalTracker_h
#define ETFGlobalTracker_h

#include "ETFTaTracker.h"

class ETFVTrack;
class ETFTimer;

class ETFGlobalTracker : public ETFTaTracker{
public:
  ETFGlobalTracker(const char *name = "");
  virtual ~ETFGlobalTracker();

  using ETFTaTracker::Map;
  virtual void Map(); ///< X tracking
  virtual void Map3D(); ///< intended not to be used for GlobalTracker
  // replace X tracks in pre/post-TaTrackers with ameliorated global ones
  void SetPostMagTrk(double k, double b){ fK3 = k; fB3 = b; }
  void SetPostMagTrk(ETFVTrack *trk);
  virtual void UpdateTracks(ETFTaTracker *pre, ETFTaTracker *post);
  virtual void Initialize();

  ClassDef(ETFGlobalTracker, 1);

protected:
  /// called by Map, to test if a hit combination is eligible
  virtual bool TestCombination(TrackType type); ///< \param type: track type
  /// \retval false: if obtained drift time out of range
  virtual bool SetDriftDistance(ETFVTrack *trk); ///< not used here
  virtual bool SetDriftDistance(ETFVTrack *preTaTrk, ETFVTrack *postTaTrk);

  ETFTimer *fTimers[2]; ///< 2 tstops correspond to pdcArrU and pdcArrD
  static double D2THREPD; ///< threshold for D2 per dot, for tracking filtering
  double fK3, fB3; ///< l: x=fK3*z+fB3, postMagTrk
};

#endif
